package com.resign.carl.iterator.api;

import com.resign.carl.iterator.entity.MenuItem;

import java.util.Iterator;
import java.util.List;

/**
 * Created by carl.zhao on 2016/6/16.
 */
public class Waitress {

    private List<Menu> menus;

    public Waitress(List<Menu> menus){
        this.menus = menus;
    }

    public List<Menu> getMenus() {
        return menus;
    }

    public void printMenu(){
        Iterator<Menu> menuIterator = menus.iterator();
        while(menuIterator.hasNext()){
            Menu menu = menuIterator.next();
            printMenu(menu.createIterator());
        }
    }

    private void printMenu(Iterator<MenuItem> iterator){
        while(iterator.hasNext()){
            MenuItem menuItem = iterator.next();
            System.out.println(menuItem.getName() + "," + menuItem.getPrice() + "--" + menuItem.getDescription());
        }
    }
}
